<template>
	<div class="wrapper">
		<!-- 返回首页 -->
		<uni-bankhome />
		<u-parse v-html="content"></u-parse>
	</div>
</template>
<script>
	import {
		getArticleDetailType
	} from "@/api/article";
	import {
		insertUserAgreement
	} from "@/api/members";
	export default {
		data() {
			return {
				res: "",
				content: '',
				way: {
					user: {
						title: "注册协议",
						type: "USER_AGREEMENT"
					},
					privacy: {
						title: "隐私政策",
						type: "PRIVACY_POLICY"
					},
					message: {
						title: "证照信息",
						type: "LICENSE_INFORMATION",
					},
					about: {
						title: "关于我们",
						type: "ABOUT",
					},
					logout: {
						title: "注销协议",
						type: "LOGOUT",
					},
					help: {
						title: "帮助中心",
						type: "HELP",
					},
					usersAndPrivacy: {
						title: "用户协议和隐私权限",
						type: "USERS_PRIVACY",
					}
				},
			};
		},
		mounted() {},
		onLoad(option) {
			uni.setNavigationBarTitle({
				title: this.way[option.type].title,
			});
			this.init(option);
		},

		methods: {
			init(option) {
				getArticleDetailType(this.way[option.type].type).then((res) => {
					console.log('res', res)
					if (res.data.success) {
						this.res = res.data.result
						let content = this.res.map(item => {
							return item.content
						})
						//展示文章
						this.content = content.join('')
						if (option.type == "usersAndPrivacy") {
							let IdList = []
							this.res.map(item => {
								return IdList.push(item.id)
							})
							let params = IdList.join(',')
							//插入阅读用户协议和隐私权限
							insertUserAgreement({
								articleId: params,
								articleType: "USERS_PRIVACY",
							})
						}
					}
				});
			},
		},
	};
</script>
<style lang="scss" scoped>
	.wrapper {
		padding: 16rpx;
	}
</style>
